//
//  AuthenTypeChoiceVM.swift
//  kxf
//
//  Created by Mac on 2024/3/6.
//

import Foundation
import UIKit

class AuthenTypeChoiceVM: UIView {
    
    let selfHeight = kFitWidth(327)
    var type = "mini"

    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: 0, y: frame.origin.y, width: SCREEN_WIDHT, height: selfHeight))
        self.backgroundColor = .white
        self.isUserInteractionEnabled = true
        self.layer.cornerRadius = kFitWidth(8)
        self.clipsToBounds = true
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var titleVm : RegisterViewHeadTitleVM = {
        let vm = RegisterViewHeadTitleVM.init(frame: CGRect.init(x: 0, y: kFitWidth(2), width: 0, height: 0))
        vm.titleLabel.text = "请选择商户类型"
        return vm
    }()
    lazy var miniMercVm : AuthenTypeItemVM = {
        let vm = AuthenTypeItemVM.init(frame: CGRect.init(x: 0, y: self.titleVm.frame.maxY, width: 0, height: 0))
        vm.titleLab.text = "小微商户"
        vm.detailLab.text = "个人形式小微商户"
        vm.setSelected(isSelect: true)
        vm.tapBlock = {()in
            self.type = "mini"
            self.geTiMercVm.setSelected(isSelect: false)
            self.qiYeMercVm.setSelected(isSelect: false)
        }
        return vm
    }()
    lazy var geTiMercVm : AuthenTypeItemVM = {
        let vm = AuthenTypeItemVM.init(frame: CGRect.init(x: 0, y: self.miniMercVm.frame.maxY, width: 0, height: 0))
        vm.titleLab.text = "个体户"
        vm.detailLab.text = "以自然人或家庭，组织的商户"
        vm.tapBlock = {()in
            self.type = "geti"
            self.miniMercVm.setSelected(isSelect: false)
            self.qiYeMercVm.setSelected(isSelect: false)
        }
        return vm
    }()
    lazy var qiYeMercVm : AuthenTypeItemVM = {
        let vm = AuthenTypeItemVM.init(frame: CGRect.init(x: 0, y: self.geTiMercVm.frame.maxY, width: 0, height: 0))
        vm.titleLab.text = "企业用户"
        vm.detailLab.text = "以注册公司，组织的商户"
        vm.tapBlock = {()in
            self.type = "qiye"
            self.geTiMercVm.setSelected(isSelect: false)
            self.miniMercVm.setSelected(isSelect: false)
        }
        return vm
    }()
}

extension AuthenTypeChoiceVM{
    func initUI() {
        addSubview(titleVm)
        addSubview(miniMercVm)
        addSubview(geTiMercVm)
        addSubview(qiYeMercVm)
        
    }
}
